package cars;

import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-11-24
 * Time: 12:31
 */
//TrunkLis存储卡车
public class TrunkList extends VehicleList{

    LinkedList<Trunk> list;
    public TrunkList(){
        list = new LinkedList<>();
        list.add(new Trunk("京2374847","东风","6t",1000));
        list.add(new Trunk("京1232333","东风","12t",1000));
        list.add(new Trunk("京4587384","雄狮","6t",2000));
        list.add(new Trunk("京1236172","雄狮","12t",2000));
    }
    public void printf(String velName){
        int number = 1;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).brand.compareTo(velName) == 0){
                System.out.print(number + "." + list.get(i).type + "   ");
                number++;
            }
        }
        System.out.println();
    }
    public Trunk find(String data1, String data2){
        for (int i = 0; i < list.size(); i++) {
            Trunk trunk = list.get(i);
            if (trunk.brand.compareTo(data1) == 0 && trunk.type.compareTo(data2) == 0){
                System.out.println(trunk.vehicleld);
                return trunk;
            }
        }
        return null;
    }

    public double getPerRent(Vehicle trunk, int days){
        if (days >= 3 && days <= 7){
            return trunk.perRent * days * 0.9;
        }else if (days >= 7 && days <= 30){
            return trunk.perRent * days * 0.8;
        }else if (days >= 30 && days <= 150){
            return trunk.perRent * days * 0.7;
        }else if (days >= 150){
            return trunk.perRent * days * 0.6;
        }else{
            return trunk.perRent * days;
        }
    }
    public int del(String data1, String data2){
        for (int i = 0; i < list.size(); i++) {
            Trunk vehicle = list.get(i);
            if (vehicle.brand.compareTo(data1) == 0 && vehicle.type.compareTo(data2) == 0){
                return i;
            }
        }
        return -1;
    }
}
